/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package alternate;

import alternate.CSVReader;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Map;

/**
 * @author Galina Bulgakova
 * @author Peter Weirich
 */
public class DecisionTree 
{
    public static void main(String[] args) throws IOException
    {
        CSVReader csvFile = new CSVReader("Table.csv");
        Map<String,ArrayList> csvContent = csvFile.getCSVasMap();
        ID3Algorithm id3 = new ID3Algorithm(csvContent, "Country", "Austria");
        id3.deleteLog();
        id3.buildTree(id3.getTable(),0);
        
//        CSVReader csvFile = new CSVReader("TennisExample.csv");
//        Map<String,ArrayList> csvContent = csvFile.getCSVasMap();
//        ID3Algorithm id3 = new ID3Algorithm(csvContent, "Tennis", "Yes");
//        id3.deleteLog();
//        id3.buildTree(id3.getTable(),0);
//        
        
        
//        System.out.println(id3.calculateHighestInformationGain().toString());
//        System.out.println(id3.splitTable("Outlook").toString());
        
//        System.out.println(id3.getNumberOfRows());
//        System.out.println(id3.getNumberOfAttributes());
//        System.out.println(id3.getTargetAttribute());
//        System.out.println(id3.getTargetAttributeValue());
//        Map<String,Integer> test = id3.countAttributeValues("Country");
//        System.out.println(test.toString());
//        System.out.println(id3.calculateTargetInformation());
//        System.out.println("-----------------------------");
//        Map<String, int[]> tst = id3.compareAttributeAndTarget("Soccer");
//        int[] tst2 = tst.get("Yes");
//        System.out.println("Hits: " + tst2[0] + "Misses: " + tst2[1]);
//        
//        Map<String,Double> te = id3.calculateAttributesWeightedInformation();
//        System.out.println(te.toString());
//        
//        System.out.println(id3.calculateHighestInformationGain().toString());
//        Map<String,Map<String,ArrayList>> testte = id3.splitTable("Soccer");
//        System.out.println(testte.toString());
//        for(Map<String,ArrayList> elem : testte.values())
//        {
//            ID3Algorithm tempID3 = new ID3Algorithm(elem, "Country", "Austria");
//            System.out.println(tempID3.calculateHighestInformationGain().toString());
//            System.out.println(tempID3.splitTable("Climbing").toString());
//            System.out.println("-------------------------------------------------");
//        }
//        
//        id3.buildTree();
    }
    
//    public static Map<String, Map> rekursion(Map<String, ArrayList> tempMap)
//    {
//        ID3Algorithm id3 = new ID3Algorithm(tempMap, "Country", "Austria");
//        Map<String,Double> infoGain = id3.calculateHighestInformationGain();
//        
//        if(infoGain != null)
//        {
//            for(String elem : infoGain.keySet())
//            {
//                System.out.println("Untersuchtes Attribut: " + elem);
//                Map<String, Map<String, ArrayList>> split = id3.splitTable(elem);
//                System.out.println(split.toString());
//                for(String rekName : split.keySet())
//                {
//                    System.out.println("Teilbaum für " + rekName);
//                    rekursion(split.get(rekName));
//                }
//            }
//        }
//        else
//        {
//            System.out.println("Ende erreicht");
//        }
//        
//        return null;
//    }
    
}
